<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="root"></div>

    <script src="./js/react.development.js"></script>
    <script src="./js/react-dom.development.js"></script>
    <script src="./js/babel.js"></script>

    <script type="text/babel">
      const list = [
        { id: 1, name: 'jack', content: 'rose, you jump i jump' },
        { id: 2, name: 'rose', content: 'jack, you see you, one day day' },
        { id: 3, name: 'tom', content: 'jack,。。。。。' },
      ]
      const div = (
        <div>
          {list.length ? (
            <ul>
              {list.map((item) => {
                return (
                  <li key={item.id} style={{ backgroundColor: 'pink' }}>
                    <a
                      href=""
                      onClick={function (e) {
                        e.preventDefault()
                        console.log(e.target.innerText)
                        // 无效. 原因: return false只有在真正的事件处理函数中才有效
                        // return false
                      }}
                    >
                      <h3 style={{ color: 'green', fontSize: 30 }}>
                        {item.name}
                      </h3>
                      <p style={{ color: 'red' }}>{item.content}</p>
                    </a>
                  </li>
                )
              })}
            </ul>
          ) : (
            <h1>暂无评论！</h1>
          )}
        </div>
      )

      ReactDOM.createRoot(document.getElementById('root')).render(div)
    </script>
  </body>
</html>
